﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace FITClub.Episode1.Controller.AI
{
    public class PseudoRandom
    {
        RandomNumberGenerator generator;
        byte[] data;

        public PseudoRandom()
        {
            generator = new RNGCryptoServiceProvider();
            data = new byte[260];
        }

        public int GetInt32()
        {
            generator.GetBytes(data);
            return BitConverter.ToInt32(data, data[1]);
        }

        public int GetInt32(int min, int max)
        {
            int val = this.GetInt32() + min;
            return val % (max + 1);
        }

        public int GetInt32(int max)
        {
            int val = this.GetInt32() % max;
            if (val < 0)
            {
                return -val;
            }
            return val;
        }
    }
}